gdk/wayland: Fix button mask calculation on button events
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 2 Nov 2022 16:11:10 +0000 (17:11 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 2 Nov 2022 16:17:43 +0000 (17:17 +0100)
commitece28bea74d49e38e3f4d55939b201c4a2a03a49
tree5db4f6300285e5b4c3290c40e1121412785aeaae
parenta272887c3490b62264bfce0085ae0043be75ce08
gdk/wayland: Fix button mask calculation on button events

There's 2 things broken here:
- The mask was calculated on top of the GDK button (i.e. skipping
  4-7 buttons), so GDK_BUTTON4_MASK and GDK_BUTTON5_MASK were not
  assigned. This is now calculated on the (continuous) BTN_ evcodes
  so it is guaranteed that the next 2 physical buttons (i.e.
  back/forward) get these two places in the mask assigned.
- Furthermore, these buttons would be pushed to places in the
  modifier mask that they didn't belong to. It is now checked hard
  that only the first 5 buttons enable a modifier flag.

Overall, this ensures that no event masks with bonkers values are
forwarded, and that no stale implicit grabs are left after additional
buttons are pressed.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5301
gdk/wayland/gdkdevice-wayland.c